﻿using System.Data;
using PolePositionMobileUtilityGeneral;

namespace PolePositionMobileUtilityEntity
{
    public class EInspector : EBaseLookup
    {
        public ECompany Company { get; set;}

        public EInspector()
            : base()
        {
            m_TableCollumnId = "InspectorId";
            m_TableName = "tb_Inspectors";
        }

        public EInspector(int id, string name)
            : this()
        {
            Id = id;
            Name = name;
        }

        public EInspector[] GetAll()
        {
            DataTable _dt = SelectAll();
            EInspector[] arr = new EInspector[_dt.Rows.Count];
            
            for (int i = 0; i < _dt.Rows.Count; i++)
            {
                arr[i] = new EInspector(ConvertMobileHelper.ToInt32(_dt.Rows[i][m_TableCollumnId]), ConvertMobileHelper.Tostring(_dt.Rows[i][m_TableCollumnName]));
                arr[i].Company = new ECompany();
                arr[i].Company.Id = ConvertMobileHelper.ToInt32(_dt.Rows[i]["CompanyFk"]);
            }

            return arr;
        }
    }
}
